<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" href="lib/layui-v2.5.5/css/layui.css" media="all">
		<link rel="stylesheet" href="css/public.css" media="all">

	</head>
	<body>
	

	<form class="layui-form layui-from-pane" action="" style="margin-top:20px" lay-filter="formAnswer">
		<input type="hidden" name="id" class="layui-input">
		
		<input type="hidden" name="userId" class="layui-input">
		
		<input type="hidden" name="questionId" class="layui-input">
		
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">问题</label>

			  <textarea name="question" id="question" class="layui-textarea" disabled></textarea>

		</div>
		
		
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">回答内容</label>

			  <textarea name="content" id="content" class="layui-textarea" disabled></textarea>

		</div>
		
		
		<div class="layui-form-item">
			<label class="layui-form-label">审核状态</label>
			<div class="layui-input-block">
			  <input type="radio" name="status" value="0" title="审核中" checked>
			  <input type="radio" name="status" value="1" title="未通过" >
			  <input type="radio" name="status" value="2" title="已通过" >
			</div>
		</div>
		
		
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">审核描述</label>
			<div class="layui-input-block">
			  <textarea name="checkDescribe" placeholder="请输入审核描述" lay-verify="required" class="layui-textarea"></textarea>
			</div>
		</div>
	
	
		<div class="layui-form-item" style="margin-top:40px">
			<div class="layui-input-block">
				<button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="demo11">提交审核</button>
				<!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
			</div>
		</div>
	</form>

<script src="lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="api/baseApi.js" charset="utf-8"></script>
<script>
		layui.use(['laydate','table','layer','form','layedit'], function(){
					var form = layui.form
					,layer = layui.layer
					$ = layui.$;
					var layedit = layui.layedit;
			
			
			//获取页面传过来的数据
			let localData = layui.sessionData("asData");

			console.log(localData.as);
			
			$.ajax({
				url: baseUrl + qsBaseUrl + localData.as.questionId,
				type: 'get',
				dataType: "json",
				contentType: "application/json;charset=UTF-8",
				success:function(res){
					console.log(res)
					localData.as.question = res.data.question
					
					//给表单赋值
					form.val('formAnswer',localData.as);
					
					form.render();

					var index1 = layedit.build('question',{
						height:50
					}); //建立编辑器

					var index2 = layedit.build('content',{
						height:150
					}); //建立编辑器
				}
			})
			

			//监听提交
			form.on('submit(demo11)', function(data) {
				//layer.msg(JSON.stringify(data.field));
				let req = data.field
				delete req.question
				delete req.content
				$.ajax({
					url: baseUrl + asUncheckBaseUrl ,
					type:'put',
					dataType: "json",
					contentType: "application/json;charset=UTF-8",
					data: JSON.stringify(req),
					success:function (res) {
						console.log(res)

						parent.layer.msg('审核已提交',{time:1000},function () {
							parent.location.reload();
						})

					}

				})

				return false;
			});
			
		});
</script>
</body>
</html>